package com.fram.controller.api;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.fram.bean.sys.ResponseMsg;
import com.fram.common.canstant.ErrCode;
import com.fram.common.exception.ProAffairException;
import com.fram.common.util.PublicMethod;
import com.fram.common.util.apiversion.ApiVersion;
import com.fram.common.util.base.BaseController;
import com.fram.entity.UserFeedback;
import com.fram.service.api.v1.UserFeedbackService;

/**
 * @作者： 陳曉鬆 @时间： 2020年11月12日 - 上午9:47:24 @description：->
 */
@RestController
@RequestMapping("/api/{version}/auth/feedback")
public class UserFeedbackController extends BaseController {

	private static Logger LOG = LoggerFactory.getLogger(UserFeedbackController.class);

	@Resource(name = "userFeedbackService")
	private UserFeedbackService userFeedbackService;

	@ApiVersion(1.0)
	@RequestMapping(value = "/add")
	private ResponseMsg add(@RequestBody UserFeedback request) {
		ResponseMsg msg = ResponseMsg.returnBeanBuild();
		try {
			request.setUserId(getApiUserId());
			userFeedbackService.add(request);
		} catch (ProAffairException e) {
			LOG.error("-内容举报-添加出错->{},{},{}", msg.getSessionId(), e.getErrorCode(), e.getErrorMsg());
			msg.setReturnCode(e.getErrorCode()).setReturnMsg(e.getErrorMsg());
		} catch (Exception e) {
			LOG.error("-内容举报-添加异常->{},{}", msg.getSessionId(), PublicMethod.printErrorTrace(e));
			msg.setReturnCode(ErrCode.ERR.getReturnCode()).setReturnMsg(ErrCode.ERR.getReturnMsg());
		}
		return msg;
	}

}
